using System.Data;
using System.Data.SqlClient;
using PetShop.BusinessEntities;
using PetShop.DataAccess.Utilities;

namespace PetShop.DataAccess.DAO
{
    public class CategoryDAO
    {
        public CategoryInfo GetCategoryByID(string categoryID)
        {
            CategoryInfo cat = null;

            string sql = "SELECT [CatId] ,[Name]  ,[Descn]  ,[BannerData]  FROM [dbo].[Category] ";

            var parm = new SqlParameter("@catId", SqlDbType.VarChar, 10);

            parm.Value = categoryID;


            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.ConnString, CommandType.Text, sql, parm))
            {
                rdr.Read();
                cat = new CategoryInfo();
                cat.CategoryID = rdr.GetString(0);
                cat.Name = rdr.GetString(1);
                cat.Description = rdr.GetString(2);
                cat.BannerData = rdr.GetString(3);
            }
            return cat;
        }
    }
}